/*
 * Copyright 2009 BioTeam Inc
 * 
 * Licensed under License GNU LESSER GENERAL PUBLIC LICENSE version 3.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.gnu.org/copyleft/lesser.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package net.bioteam.appweb.gwt.apps.client.user;

import net.bioteam.appweb.gwt.apps.client.StaticHolder;

import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.ImgButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;

public class UsersPanel extends SectionStack
{
	public UsersPanel()
	{
		super();
		// setBorder("3px solid dark");
		setWidth(500);
		setHeight100();

		SectionStackSection section = new SectionStackSection();
		section.setCanCollapse(false);
		section.setExpanded(true);

		

		Img info = new Img("[SKIN]/actions/help.png");
		info.setWidth(18);
		info.setHeight(18);
		info.setPrompt("<p>Double Click to start Editing.</p>");
		info.setHoverWidth(200);

		ImgButton refresh = new ImgButton();
		refresh.setSrc("[SKIN]actions/refresh.png");
		refresh.setSize(16);
		refresh.setShowFocused(false);
		refresh.setShowRollOver(false);
		refresh.setShowDown(false);
		refresh.setPrompt("reload");
		refresh.addClickHandler(new ClickHandler()
		{

			public void onClick(ClickEvent event)
			{
				StaticHolder.getUsersGrid().reload();
			}
		});

		ImgButton addButton = new ImgButton();
		addButton.setSrc("[SKIN]actions/add.png");
		addButton.setSize(16);
		addButton.setShowFocused(false);
		addButton.setShowRollOver(false);
		addButton.setShowDown(false);

		addButton.addClickHandler(new ClickHandler()
		{

			public void onClick(ClickEvent event)
			{
				final UsersGrid usersGrid = StaticHolder.getUsersGrid();
				usersGrid.startEditingNew();

			}
		});

		UsersGrid usersGrid = new UsersGrid();
		StaticHolder.setUsersGrid(usersGrid);


		section.setControls(info, refresh, addButton);
		section.setItems(usersGrid);
		this.setSections(section);
		
		
	}
}
